home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / src / net / omniORB-2.5.0-src.tar.gz / omniORB-2.5.0-src.tar / omniORB_2.5.0 / include / omniORB2 / IOP.h < prev    next >
C/C++ Source or Header  |  1997-12-09  |  6KB  |  182 lines

  1. // -*- Mode: C++; -*-
  2. //                            Package   : omniORB2
  3. // IOP.h                      Created on: 8/2/96
  4. //                            Author    : Sai Lai Lo (sll)
  5. //
  6. //    Copyright (C) 1996, 1997 Olivetti & Oracle Research Laboratory
  7. //
  8. //    This file is part of the omniORB library
  9. //
  10. //    The omniORB library is free software; you can redistribute it and/or
  11. //    modify it under the terms of the GNU Library General Public
  12. //    License as published by the Free Software Foundation; either
  13. //    version 2 of the License, or (at your option) any later version.
  14. //
  15. //    This library is distributed in the hope that it will be useful,
  16. //    but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  18. //    Library General Public License for more details.
  19. //
  20. //    You should have received a copy of the GNU Library General Public
  21. //    License along with this library; if not, write to the Free
  22. //    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  
  23. //    02111-1307, USA
  24. //
  25. //
  26. // Description:
  27. //       C++ mapping of the OMG IOP module
  28. //       Reference: CORBA V2.0 10.6.2
  29. //    
  30. //    
  31.  
  32. /*
  33.   $Log: IOP.h,v $
  34.   Revision 1.3  1997/12/09 20:36:28  sll
  35.   Added TaggedProfileList_var class.
  36.  
  37.  * Revision 1.2  1997/05/06  16:07:17  sll
  38.  * Public release.
  39.  *
  40.  */
  41.  
  42. #ifndef __IOP_H__
  43. #define __IOP_H__
  44.  
  45. class _OMNIORB2_NTDLL_ IOP {
  46. public:
  47.   typedef _CORBA_ULong ProfileId;
  48.   static const   ProfileId    TAG_INTERNET_IOP;
  49.   static const   ProfileId    TAG_MULTIPLE_COMPONENTS;
  50.  
  51.   struct TaggedProfile {
  52.     ProfileId tag;
  53.     _CORBA_Unbounded_Sequence_Octet profile_data;
  54.  
  55.     // the following are omniORB2 private functions
  56.     size_t NP_alignedSize(size_t initialoffset) {
  57.       size_t alignedsize = ((initialoffset+3) & ~((int)3))
  58.          + sizeof(ProfileId);
  59.       return profile_data.NP_alignedSize(alignedsize);
  60.     }
  61.     void operator>>= (NetBufferedStream &s);
  62.     void operator<<= (NetBufferedStream &s);
  63.     void operator>>= (MemBufferedStream &s);
  64.     void operator<<= (MemBufferedStream &s);
  65.   };
  66.  
  67.   typedef _CORBA_Unbounded_Sequence<TaggedProfile> TaggedProfileList;
  68.   class TaggedProfileList_var {
  69.   public:
  70.     TaggedProfileList_var() { _ptr = 0; }
  71.     TaggedProfileList_var(TaggedProfileList* p) { _ptr = p; }
  72.     TaggedProfileList_var(TaggedProfileList_var& p);
  73.     ~TaggedProfileList_var() { if (_ptr) delete _ptr; }
  74.     TaggedProfileList_var& operator= (const TaggedProfileList_var& p) {
  75.       if (p._ptr) {
  76.     if (!_ptr) {
  77.       _ptr = new TaggedProfileList;
  78.       if (!_ptr) {
  79.         _CORBA_new_operator_return_null();
  80.         // never reach here
  81.       }
  82.     }
  83.     *_ptr = *p._ptr;
  84.       }
  85.       else {
  86.     if (_ptr) delete _ptr;
  87.     _ptr = 0;
  88.       }
  89.       return *this;
  90.     }
  91.     TaggedProfileList_var& operator= (TaggedProfileList* p) {
  92.       if (_ptr) delete _ptr;
  93.       _ptr = p;
  94.       return *this;
  95.     }
  96.     TaggedProfile& operator[] (_CORBA_ULong index) { 
  97.       return (_ptr->NP_data())[index]; 
  98.     }
  99.     const TaggedProfile& operator[] (_CORBA_ULong index) const {
  100.       return (_ptr->NP_data())[index];
  101.     }
  102.     inline TaggedProfileList* operator->() const { 
  103.       return (TaggedProfileList*)_ptr; 
  104.     }
  105.     TaggedProfileList* _ptr;
  106.   };
  107.  
  108.   struct IOR {
  109.     _CORBA_Char       *type_id;
  110.     TaggedProfileList  profiles;
  111.  
  112.     // the following are omniORB2 private functions
  113.     size_t NP_alignedSize(size_t initialoffset) {
  114.       size_t alignedsize = ((initialoffset+3) & ~((int)3))
  115.          + sizeof(_CORBA_ULong);
  116.       alignedsize += strlen((const char *)type_id) + 1;
  117.       return profiles.NP_alignedSize(alignedsize);
  118.     }
  119.   };
  120.  
  121.   typedef _CORBA_ULong ComponentId;
  122.  
  123.   struct TaggedComponent {
  124.     ComponentId                tag;
  125.     _CORBA_Unbounded_Sequence_Octet component_data;
  126.  
  127.     // the following are omniORB2 private functions
  128.     size_t NP_alignedSize(size_t initialoffset) {
  129.       size_t alignedsize = ((initialoffset+3) & ~((int)3))
  130.          + sizeof(_CORBA_ULong);
  131.       return component_data.NP_alignedSize(alignedsize);
  132.     }
  133.     void operator>>= (NetBufferedStream &s);
  134.     void operator<<= (NetBufferedStream &s);
  135.     void operator>>= (MemBufferedStream &s);
  136.     void operator<<= (MemBufferedStream &s);
  137.   };
  138.   
  139.   typedef _CORBA_Unbounded_Sequence<TaggedComponent> MultipleComponentProfile;
  140.  
  141.   typedef _CORBA_ULong ServiceID;
  142.  
  143.   struct ServiceContext {
  144.     ServiceID              context_id;
  145.     _CORBA_Unbounded_Sequence_Octet context_data;
  146.  
  147.     // the following are omniORB2 private functions
  148.     size_t NP_alignedSize(size_t initialoffset) {
  149.       size_t alignedsize = ((initialoffset+3) & ~((int)3))
  150.          + sizeof(_CORBA_ULong);
  151.       return context_data.NP_alignedSize(alignedsize);
  152.     }
  153.     void operator>>= (NetBufferedStream &s);
  154.     void operator<<= (NetBufferedStream &s);
  155.     void operator>>= (MemBufferedStream &s);
  156.     void operator<<= (MemBufferedStream &s);
  157.   };
  158.  
  159.   typedef _CORBA_Unbounded_Sequence<ServiceContext> ServiceContextList;
  160.  
  161.   static const ServiceID TransactionService;
  162.  
  163.  
  164.   // omniORB2 private function
  165.   static _CORBA_Char * iorToEncapStr(const _CORBA_Char *type_id,
  166.                      const TaggedProfileList *profiles);
  167.   // returns a heap allocated and stringified IOR representation
  168.   // (ref CORBA 2 spec. 10.6.5)
  169.  
  170.   // omniORB2 private function
  171.   static void EncapStrToIor(const _CORBA_Char *str,
  172.                 _CORBA_Char *&type_id,
  173.                 TaggedProfileList *&profiles);
  174.   // returns the type id and the tagged profile list encapsulated in
  175.   // the stringified IOR representation. Both return values are heap
  176.   // allocated.
  177.   // (ref CORBA 2 spec. 10.6.5)
  178.  
  179. };
  180.  
  181. #endif // __IOP_H__
  182.